import java.io.IOException;
import java.io.InputStream;

import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;


public class TestPOI {

	public  static void main(String []args) throws IOException{
	   ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
	   InputStream in = classLoader.getResourceAsStream("WIRawDataFinal.xls");
	   HSSFWorkbook wb = new HSSFWorkbook(in);
	   System.out.println(wb.getNumberOfSheets());
	   for (int k = 0; k < wb.getNumberOfSheets(); k++) {
		   HSSFSheet sheet = wb.getSheetAt(k);
			int rows = sheet.getPhysicalNumberOfRows();
			System.out.println("Sheet " + k + " \"" + wb.getSheetName(k) + "\" has " + rows
					+ " row(s).");
	   }
	   HSSFSheet sheet = wb.getSheet("Indicators");
	   int rows = sheet.getPhysicalNumberOfRows();
			for (int r = 0; r < rows; r++) {
				HSSFRow row = sheet.getRow(r);
				if (row == null) {
					continue;
				}

				int cells = row.getPhysicalNumberOfCells();
				System.out.println("\nROW " + row.getRowNum() + " has " + cells
						+ " cell(s).");
				for (int c = 0; c < cells; c++) {
					HSSFCell cell = row.getCell(c);
					String value = null;
					if (cell != null){
						switch (cell.getCellType()) {

						case HSSFCell.CELL_TYPE_FORMULA:
							value = "FORMULA value=" + cell.getCellFormula();
							break;

						case HSSFCell.CELL_TYPE_NUMERIC:
							value = "NUMERIC value=" + cell.getNumericCellValue();
							break;

						case HSSFCell.CELL_TYPE_STRING:
							value = "STRING value=" + cell.getStringCellValue();
							break;

						default:
					}
					System.out.println("CELL col=" + cell.getColumnIndex() + " VALUE="
							+ value);
				}
					}
					
			}
		}
	
}
